package com.dks.controller.publicCompoment;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import com.dks.dto.publicCompoment.PublicAttentionDto;
import com.dks.enumeration.PublicAttentionEntityType;
import com.dks.models.publicCompoment.PublicAttention;
import com.dks.repository.IPublicAttentionRepository;
import com.dks.result.ResultModel;
import com.dks.vo.publicCompoment.PublicAttentionUserVo;

/**
 * 公共-关注
 */
@RestController
@RequestMapping("attention")
public class PublicAttentionController{

    @Autowired
    private IPublicAttentionRepository publicAttentionRepository;


    /**
     * 关注/取消关注
     * @author evan
     */
    @PostMapping("")
    public ResultModel<PublicAttention> attention(@RequestBody @Validated PublicAttentionDto publicAttentionDto) {
        return publicAttentionRepository.attention(publicAttentionDto);
    }

    /**
     * 获取当前用户关注的用户列表
     * @author evan
     */
    @GetMapping("me-attention/{userId}/{attentionEntityType}")
    public ResultModel<List<PublicAttentionUserVo>> getMeAttention(@PathVariable("userId")Long userId, @PathVariable("attentionEntityType")PublicAttentionEntityType publicAttentionEntityType){
        return publicAttentionRepository.getMeAttention(userId, publicAttentionEntityType);
    }


    /**
     * 获取关注当前用户的用户列表
     * @author evan
     */
    @GetMapping("attention-me/{userId}/{userType}")
    public ResultModel<List<PublicAttentionUserVo>> getAttentionMe(@PathVariable("userId")Long userId, @PathVariable("userType")PublicAttentionEntityType userType,
                                                                   @RequestParam(value = "attentionEntityType", required = false)PublicAttentionEntityType publicAttentionEntityType){
        return publicAttentionRepository.getAttentionMe(userId, userType, publicAttentionEntityType);
    }

}
